package com.songminju.sqlsong.exector;

import java.sql.ResultSet;
import java.sql.SQLException;

public interface SsqlExecutor {
	interface CallBack<T>{
		enum CallBackEvent{
			SUCCESS,EXCEPTION;
		}
		//只有成功时resultSet不为null
		T call(CallBackEvent e,ResultSet rs,Exception excp);
	}
	
	//基本的curd操作
	ResultSet exec(String ssql);
	//返回T类型的ClaaBack.call(...)的返回值
	<T> T exec(String ssql,CallBack<T> call);
	
	ResultSet exec(String ssql,Object ...objects);
	<T> T exec(String ssql,CallBack<T> call,Object ...objects);
	
	//事务操作
	boolean tryBeginTransaction();
	boolean tryCommit();
	void beginTransaction() throws SQLException;
	void commit() throws SQLException ;
	void rollback() throws SQLException ;
	void close();
	
}
